﻿using ASPNETVN.PORTAL.Components.UI;
using ASPNETVN.PORTAL.Modules.EX.Components;
using ASPNETVN.PORTAL.Components.Security;
using ASPNETVN.PORTAL.Components.Helpers;
using System;
using System.Data;
using System.Web.UI.WebControls;
using System.Web.UI;

namespace ASPNETVN.PORTAL.Modules.EX.Controls
{
    public partial class AddEditItem : AddEditItemControl
    {
        protected override void OnInit(EventArgs e)
        {
            this.ButtonUpdate = btnSave;
            this.ButtonCancel = btnCancel;

            this.Update += new EventHandler(AddEditItem_Update);     
            base.OnInit(e);
        }

        void AddEditItem_Update(object sender, EventArgs e)
        {
            //try
            //{
            //    // Lưu thông tin vào CSDL.
            //    Item rate = new Item();
            //    rate.CurrenrcyName = ddlCode.SelectedItem.Text;
            //    rate.ExchangeRate = decimal.Parse(txtRate.Text.Trim());
            //    rate.FromDate = DateTime.Parse(txtTuNgay.Text.Trim());
            //    rate.ToDate = DateTime.Parse(txtDenNgay.Text.Trim());
            //    rate.CreatedBy = PortalSecurity.CurrentUser.Identity.Email;
            //    rate.CreatedDate = DateTime.Now;

            //    if (this.ItemID == 0)
            //    {
            //        this.ItemID = rate.Insert();
            //    }
            //    else
            //    {
            //        rate.ID = this.ItemID;
            //        rate.Update();
            //    }

            //    txtRate.Text = "";                
            //}
            //catch (Exception ex)
            //{
            //    throw new Exception(ex.Message);
            //}
                   
        }

       protected void Page_Load(object sender, EventArgs e)
        {
            // First time load page.
            if (!Page.IsPostBack)
            {                
                txtTuNgay.Text = DateTime.Now.ToShortDateString();
                txtDenNgay.Text = DateTime.Now.ToShortDateString();
            }
        }

        //protected void gridServers_RowCommand(object sender, GridViewCommandEventArgs e) {
        //    if (e.CommandName.Equals("rowcmdDelete"))
        //    {
        //        gvExchangeRate.Columns[0].Visible = true;
        //        sqlSourceExchangeRate.DeleteParameters[0].DefaultValue = gvExchangeRate.SelectedRow.Cells[0].ToString();
        //        sqlSourceExchangeRate.Delete();

        //        gvExchangeRate.DataBind();
        //        gvExchangeRate.Columns[0].Visible = false;
        //    }
        //}
  


    }
}